from django.contrib.auth.forms import UserCreationForm
from django.shortcuts import render, redirect
from django.contrib.auth import login as auth_login

from accounts.forms import SignUpForm


# Create your views here.


def signup(request):
    if request.method == 'POST':
        # form = UserCreationForm(request.POST)
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            auth_login(request,user)
            return redirect('Home')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})